import axios from './request';
import qs from 'qs'

// 精品推荐接口
export const tuijianApi = () => axios.get("/products/recommend");
// 热门兑换接口
export const remenApi = () => axios.get("/products/hot");
// 商品详情
export const detailApi = (id) => axios.get(`/products/${id}`);
// 获取用户信息
export const userApi = () => axios.get("/shop/userProfiles");
// 商品搜索（含首页的“更多”）
export const goodsApi = (params) => axios.get("/products", { params: params });

// 查看购物车
export const gouwucheApi = () => axios.get("/shop/carts");

// 加入到购物车
export const addcartApi = (params) => axios.post("/shop/carts/add", qs.stringify(params));

// 发送注册短信验证码
export const sendSMSApi = (params) => axios.post("/sendSMS", qs.stringify(params));

// 手机号验证码登录(含注册)
export const phoneReginApi = (params) => axios.post("/phoneRegin", qs.stringify(params));

// 微信扫码登录
export const wechatApi = (params) => axios.post("/wechatUsers/PCLogin", qs.stringify(params));

// 手机绑定微信
export const bandingApi = (params) => axios.post("/wechatUsers/binding", qs.stringify(params));

// 获取用户信息
export const getuserApi = () => axios.get("/shop/userProfiles");




// 获取url参数
export function getUrl() {
  let h1 = location.href;
  let h2 = h1.split("?");
  let h3 = h2[1].split("=");
  if (h3[0] == "did") {
    return h3[1];
  } else {
    return 0
  }
}